﻿using FangChanCrm.Services.Interface;
using FangChanCrmModel;
using Maticsoft.Model;
using Microsoft.AspNetCore.Mvc;
using Microsoft.EntityFrameworkCore.Metadata.Internal;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;

namespace FangChanCrm.Controllers
{
    public class PhoneGongGaoController : Controller
    {
        private readonly It_GongGaoBiaoService t_GongGaoBiaoService;
        private readonly It_RenYuanBiaoService t_RenYuanBiaoService;
        public PhoneGongGaoController(It_GongGaoBiaoService GongGaoBiaoService, It_RenYuanBiaoService RenYuanBiaoService)
        {
            t_GongGaoBiaoService = GongGaoBiaoService;
            t_RenYuanBiaoService = RenYuanBiaoService;
        }
        
        public IActionResult PhoneGongGaoList()
        {
            return View();
        }
        public IActionResult PhoneGongGaoShenPi()
        {
            return View();
        }
        public string Getgonggaolist() 
        {
            List<t_GongGaoBiao> list = t_GongGaoBiaoService.GetList().Where(x=>x.BeiZhu2=="待审批").ToList();
            string shuju = "";
            for (int i = 0; i < list.Count; i++)
            {
                t_RenYuanBiao t_RenYuanBiao = t_RenYuanBiaoService.GetById(list[i].FangBuRenId);
                shuju += "<li class='list-item' onclick=\"tiaozhuanyemian('"+list[i].Id+"')\"><div class='item-top'><div></div><span>"+list[i].BeiZhu3+"</span></div><div class='item-bottom' style='display: flex;justify-content: space-between;'><div class='classroom'><span>日期：</span><span>"+list[i].BeiZhu1+"</span></div><div class='unsold'><span>发布人：</span><span>"+ t_RenYuanBiao.XingMing + "</span></div></div></li>";
            }
            return shuju;
        }
        public string PhoneGongGaoShenPiXinXi() 
        {
            string id = Request.Form["Id"];
            t_GongGaoBiao t_GongGaoBiao = t_GongGaoBiaoService.GetId(Convert.ToInt32(id));
            t_RenYuanBiao t_RenYuanBiao = t_RenYuanBiaoService.GetById(t_GongGaoBiao.FangBuRenId);
            string json = "[{\"BiaoTi\":\"" + t_GongGaoBiao.BeiZhu3 + "\",\"ShiJian\":\"" + t_GongGaoBiao.BeiZhu1 + "\",\"FaBuRen\":\"" + t_RenYuanBiao.XingMing + "\",\"NeiRong\":\"" + t_GongGaoBiao.GongGaoNeiRong + "\"}]";
            return json;
        }
    }
}
